home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / AmigaE / Src / Utils / EDBG / sctext.e < prev   
Encoding:
Text File  |  1997-10-26  |  2.7 KB  |  108 lines

  1. -> implementation of textscrollerwindow class, subclass of scrollwin
  2.  
  3. OPT MODULE
  4.  
  5. MODULE 'class/sc'
  6. MODULE 'intuition/intuition', 'intuition/screens',
  7.        'graphics/rastport', 'graphics/gfxbase', 'graphics/text'
  8.  
  9. EXPORT OBJECT scrolltext OF scrollwin PRIVATE
  10.   font:PTR TO textfont
  11.   lines, cols
  12.   tlist:PTR TO LONG
  13.   ox,oy,oxs,oys
  14.   current,ocurrent,curvis
  15. ENDOBJECT
  16.  
  17. PROC settext(textlist,width) OF scrolltext
  18.   self.lines:=ListLen(textlist)
  19.   self.cols:=width
  20.   self.tlist:=textlist
  21.   self.current:=-1
  22.   self.ocurrent:=-1
  23.   self.curvis:=FALSE
  24. ENDPROC
  25.  
  26. PROC refreshwindow() OF scrolltext
  27.   self.ox:=0
  28.   self.oy:=0
  29.   self.oxs:=0
  30.   self.oys:=0
  31.   SUPER self.refreshwindow()
  32. ENDPROC
  33.  
  34. PROC getactive() OF scrolltext IS self.current
  35.  
  36. PROC active(cur,dorefresh=TRUE) OF scrolltext
  37.   self.current:=cur
  38.   IF dorefresh THEN IF (cur<self.oy) OR (self.oy+self.oys<=cur) THEN self.settop(cur-(self.oys/2)) ELSE SUPER self.refreshwindow()
  39. ENDPROC
  40.  
  41. PROC extra_refresh(x,y,xs,ys,xoff,yoff,win:PTR TO window) OF scrolltext
  42.   DEF fx,fy,a,b,yc,base,s,r:PTR TO rastport,ny,nys,bot,de=TRUE
  43.   r:=stdrast:=win.rport
  44.   fx:=self.font.xsize
  45.   fy:=self.font.ysize
  46.   SetFont(r,self.font)
  47.   base:=self.font.baseline
  48.   bot:=win.height-win.borderbottom-1
  49.   r.mask:=1
  50.   IF ((a:=self.ocurrent)>=0) AND self.curvis
  51.     a:=a-self.oy*fy+yoff
  52.     ClipBlit(r,xoff,a,r,xoff,a,xs*fx,fy,$50)
  53.     self.curvis:=FALSE
  54.   ENDIF
  55.   ny:=y; nys:=ys
  56.   IF (self.ox=x) AND (self.oxs=xs) AND (self.oys=ys)
  57.     IF (a:=self.oy-y)<>0
  58.       IF ys>Abs(a)                    -> only max half display
  59.         IF a>0                        -> scroll up
  60.           ClipBlit(r,xoff,yoff,r,xoff,a*fy+yoff,xs*fx,(b:=ys-a)*fy,$C0)
  61.           ys:=a
  62.           bot:=a*fy+yoff-1
  63.         ELSE                        -> scroll down
  64.           a:=Abs(a)
  65.           ClipBlit(r,xoff,a*fy+yoff,r,xoff,yoff,xs*fx,(b:=ys-a)*fy,$C0)
  66.           y:=y+b
  67.           yoff:=b*fy+yoff
  68.           ys:=a
  69.         ENDIF
  70.       ENDIF
  71.     ELSE
  72.       de:=FALSE
  73.     ENDIF
  74.   ENDIF
  75.   IF de
  76.     Box(xoff,yoff,win.width-win.borderright-1,bot,0)
  77.     Colour(1)
  78.     FOR a:=0 TO ys-1
  79.       yc:=a*fy+yoff
  80.       s:=IF a+y<ListLen(self.tlist) THEN self.tlist[a+y] ELSE ''
  81.       IF x THEN FOR b:=1 TO x DO IF s[] THEN s++
  82.       Move(r,xoff,yc+base)
  83.       Text(r,s,Min(xs,StrLen(s)))
  84.     ENDFOR
  85.   ENDIF
  86.   IF (a:=self.current)>=0
  87.     IF (a>=ny) AND (ny+nys>a)
  88.       a:=a-y*fy+yoff
  89.       ClipBlit(r,xoff,a,r,xoff,a,xs*fx,fy,$50)
  90.       self.curvis:=TRUE
  91.     ENDIF
  92.   ENDIF
  93.   self.ox:=x
  94.   self.oy:=ny
  95.   self.oxs:=xs
  96.   self.oys:=nys
  97.   self.ocurrent:=self.current
  98. ENDPROC
  99.  
  100. PROC extra_init(screen:PTR TO screen) OF scrolltext
  101.   DEF gb:PTR TO gfxbase
  102.   gb:=gfxbase
  103.   self.font:=gb.defaultfont    -> needs openfont?
  104. ENDPROC
  105.  
  106. PROC extra_unit() OF scrolltext IS self.font.xsize, self.font.ysize
  107. PROC extra_max() OF scrolltext IS self.cols, self.lines
  108.